package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.Customer;
import com.atguigu.jxc.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 *
 * @Author 花鸟の虫鱼
 * @CreateDate 21/9/5 21:07
 * @Version 1.0
 * @Description TODO
 */
@RestController
@RequestMapping("/customer")
public class CustomerController {

    @Autowired
    private CustomerService customerService;

    /**
     * @param page         当前页数
     * @param rows         每页显示的记录数
     * @param customerName
     * @return
     */
    @RequestMapping("/list")
    public Map<String, Object> list(Integer page, Integer rows, String customerName) {
        return customerService.list(page, rows, customerName);
    }

    /**
     * 添加或修改角色信息
     * @param customer 供应商角色信息
     * @return
     */
    @RequestMapping("/save")
    public ServiceVO save(Customer customer, @RequestParam(required = false) Integer customerId) {
        customer.setCustomerId(customerId);
        return customerService.save(customer);
    }

    /**
     * 删除角色,支持批量删除
     * @param ids 供应商id
     * @return
     */
    @RequestMapping("/delete")
    public ServiceVO delete(String ids) {
        return customerService.delete(ids);
    }
}
